/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __BLENDER_LOAD_IMPL_H__
#define __BLENDER_LOAD_IMPL_H__

#include "blender.h"
#include "bMain.h"
#include "bBlenderFile.h"

#include "SceneObject.h"

namespace GNgine
{
	class BlenderLoadImpl
		: public SceneResourceLoadImpl
	{
	public:
		BlenderLoadImpl(SceneObject* sceneObject,std::string path);
		Object* load();

		inline bool success()
		{
			return _success;
		}
	private:
		bool parseBlend();//read and parse blender file
		void convertObjects();//convert blend data to graphic object
		void convertObject(Blender::Object *object);

		void convertMeshObject(Blender::Object *object);
		void convertLampObject(Blender::Object *object);
		void convertCameraObject(Blender::Object *object);
		void convertEmptyObject(Blender::Object *object);
		void convertArmatureObject(Blender::Object *object);

		void createParentChildHierarchy();
		void convertConstraints();

		void beginScene(Blender::Scene *scene);
	private:
		bool _success;

		short _bAnimRate;//blender animation rate
		bParse::bBlenderFile* _bFile;//blender file in blender parser
		Blender::Scene* _bScene;//blender scene

		Ogre::ColourValue _ambient;//scene ambient color;
		Ogre::ColourValue _worldColor;//???background?

	};
}
#endif
